package com.clkj.xiuzheng.dao;

import com.clkj.xiuzheng.pojo.ShopVisit;
import com.clkj.xiuzheng.pojo.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;
import java.util.Map;

/**
 * @author yawang
 * @create 2024/05/06 17:40:29
 **/
@Repository
public interface ShopVisitMapper extends Mapper<ShopVisit> {

    @Select("select a.*,b.shop_name,u.user_name from t_cl_shopVisit a  " +
            "left join t_cl_shop b on a.shop_id = b.shop_id " +
            "left join t_cl_user u on a.user_id = u.user_id where a.user_id = #{userId}")
    List<ShopVisit> selectVisitByUser(@Param("userId")Integer userId);

    @Select("<script>" +
            "select a.*,b.shop_name,c.user_name from t_cl_shopVisit a " +
            "left join t_cl_shop b on a.shop_id = b.shop_id " +
            "left join t_cl_user c on a.user_id = c.user_id " +
            "where 0=0 " +
            "<if test='userId !=-1'> and a.user_id  =#{userId} </if>" +
            "<if test='status !=-1'> and a.visit_apply  =#{status} </if>" +
            "order by a.visit_date desc"+
            "</script>")
    List<ShopVisit> selectVisit(@Param("userId") Integer userId, @Param("status") Integer status);



}
